package com.hongyuan.sellfitness.ui.person.view_mode;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.hongyuan.mvvmhabitx.binding.command.BindingAction;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.sellfitness.base.ItemViewModel;
import com.hongyuan.sellfitness.ui.find.beans.FindChildTopBean;
import com.hongyuan.sellfitness.ui.person.activity.UserInfoActivity;

public class FansItemViewModel extends ItemViewModel<FansViewModel> {

    public ObservableField<FindChildTopBean.ListBean> entity = new ObservableField<>();

    public FansItemViewModel(@NonNull FansViewModel viewModel, FindChildTopBean.ListBean bean) {
        super(viewModel);
        entity.set(bean);
    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Bundle bundle = new Bundle();
            bundle.putString("user_id",String.valueOf(entity.get().getM_id()));
            bundle.putString("userPhone",entity.get().getM_mobile());
            viewModel.startActivity(UserInfoActivity.class,bundle);
        }
    });

    //关注ta
    public BindingCommand attention = new BindingCommand(new BindingAction() {
        @Override
        public void call() {

            if(entity.get().getIs_xh() != 1){
                //设置要操作的对象
                viewModel.itemClick(FansItemViewModel.this);

                //弹框提示是否需要操作
                viewModel.uc.showCancel.call();
            }
        }
    });
}
